package top.jolyoulu.codegenweb.entity.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import top.jolyoulu.codegenweb.entity.po.DataSourceInfo;

import javax.validation.constraints.NotNull;
import java.util.Objects;

/**
 * @Author: JolyouLu
 * @Date: 2023/3/25 15:45
 * @Description
 */
@Data
public class DataSourceInfoVO {

    /** id */
    private String id;

    /** 数据库类型(1.mysql) */
    private Integer databaseType;

    /** 连接地址 */
    private String host;

    /** 连接端口 */
    private String port;

    /** 库名 */
    private String schemaName;

    /** 用户名 */
    private String username;

    public DataSourceInfoVO(DataSourceInfo dataSourceInfo) {
        if (Objects.nonNull(dataSourceInfo)){
            this.id = dataSourceInfo.getId();
            this.databaseType = dataSourceInfo.getDatabaseType();
            this.schemaName = dataSourceInfo.getSchemaName();
            this.host = dataSourceInfo.getHost();
            this.port = dataSourceInfo.getPort();
            this.username = dataSourceInfo.getUsername();
        }
    }
}
